package net.hn.hnms.biz.safety.wind.Service;

import net.hn.hnms.biz.safety.wind.Dao.DevicefaultDao;
import net.hn.hnms.biz.safety.wind.entity.DevicefaultEntity;
import net.hn.hnms.biz.safety.wind.entity.DevicefaultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 智呈物联 nzw
 * @date 2022/12/27
 */
@Service
public class DevicefaultService {

    private DevicefaultDao devicefaultDao;

    @Autowired
    public void setDevicefaultDao(DevicefaultDao devicefaultDao) {
        this.devicefaultDao = devicefaultDao;
    }

    public List<DevicefaultVO> findDevicefault(String mineCode){
        List<DevicefaultEntity> list = devicefaultDao.findAllByMineCode(mineCode);
        List<DevicefaultVO> devicefaultVOList = new ArrayList<>();

        for(DevicefaultEntity devicefaultEntity:list){
            DevicefaultVO devicefaultVO = new DevicefaultVO();
            devicefaultVO.setCurrentState(devicefaultEntity.getCurrentState());
            devicefaultVO.setReason(devicefaultEntity.getReason());
            devicefaultVO.setSourceName(devicefaultEntity.getSourceName());
            devicefaultVO.setStartTime(devicefaultEntity.getStartTime());

            devicefaultVOList.add(devicefaultVO);
        }

        return devicefaultVOList;
    }
}
